#ifndef ADDAO_H
#define ADDAO_H

#define AD_DB_PATH "/home/guoxi/ronghua_ads/ads.db"

typedef struct AdResource
{
    int id;
    int ad_id;
    int type_id;
    char* path;
    char* sign;
    int index;
} AdResource;

typedef struct Ad
{
    //广告本身信息
    int id;
    int template_id;
    int customer_id;
    char* start_time;
    char* end_time;
    int state;
    int index;

    //广告资源
    AdResource *resources[3];
} Ad;


int saveAd(Ad *ad);
int updateAd(Ad *ad);
Ad* getAd(int id);


int saveAr(AdResource *ar);
int updateAr(AdResource *ar);
AdResource* getAr(int adid,int index);

int clearExpireAd();

#endif